<template>
  <div>
  <div class="block">
    <el-carousel height="300px">
      <el-carousel-item v-for="one in dataList" :key="one">
        <img style="heith:10%;width:100%"
             :src="'http://localhost:8071'+one.newImg" alt=""
        >
      </el-carousel-item>
    </el-carousel>
  </div>
  <div class="msg-table">
    <el-table
      :data="dataList"
      height="330"
      border
      style="width: 100%">
      <el-table-column
        prop="newTitle"
        label="标题"
        width="180">
      </el-table-column>
      <el-table-column
        prop="newTime"
        label="时间"
        width="180">
      </el-table-column>
      <!--<el-table-column-->
        <!--prop=""-->
        <!--label="发布人"-->
        <!--width="180">-->
      <!--</el-table-column>-->
        <el-table-column
          prop="newContent"
          label="内容">
          <template slot-scope="scope">
            <div v-html="scope.row.newContent"></div>
          </template>
        </el-table-column>
    </el-table>
    <div class="page">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="pagination.currentPage"
        :page-size="pagination.pageSize"
        layout="total, prev, pager, next"
        :total="pagination.totals">
      </el-pagination>
    </div>
  </div>
  </div>
</template>

<script>
  import Common from '@/components/common/Common'
    const axios=require("axios");
    export default {
        name: "informationCenter" ,
        created: function () {
            this.getData();
        },
        data() {
            return {
                dataList: [],
                pagination: {
                    pageSize: 6, // 显示的条数
                    totals: 12, // 总数
                    currentPage: 1, // 当前第几页
                },
                form:{
                    search:"",
                    data:[new Date(2020, 10, 10, 10, 10), new Date(2021, 10, 11, 10, 10)],
                    startTime:"",
                    endTime:""
                },
            }
        },
        methods:{
            getData(){
                var vm=this;
                axios.post(Common.API+'news/getNews',{
                    startTime:vm.form.data[0],
                    endTime:vm.form.data[1],
                    news:{
                        newStatus:"过审核",
                        newTitle:vm.form.search,
                    },
                    page:{
                        current:vm.pagination.currentPage,
                        size:vm.pagination.pageSize,
                    }
                })
                    .then(function (res) {
                        vm.pagination.totals=res.data.total;
                        vm.dataList=res.data.records;
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            handleCurrentChange(val){
                this.pagination.currentPage=val;
                this.getData();
            },
            getAuthor(){

            }
        }
    }
</script>

<style scoped>
  .block{
    width: 70%;
    margin: auto; /* 上下间距160px，左右自动居中*/
  }

  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }

  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }

  .msg-table{
    margin-top: 1.5em;
    width: 95%;
  }

  .page{
    width: 70%;
    margin: 1em auto; /* 上下间距160px，左右自动居中*/
  }

</style>
